﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;

namespace Domotica.Gazing.Calibration
{
    internal class QuickProcessor : Processor
    {
        public QuickProcessor(Calibrator calibrator) 
            : base(calibrator, CalibrationState.Smoothing)
        {
        }

        private Point _Center;
        protected override ProcessList Initialize()
        {
            ProcessList l = new ProcessList();

            CalibratorScreen primary = Calibrator.ScreenList.GetPrimary();
            _Center = primary.GetCenter();
            l.Add(new ProcessSetForm(primary.GetCenter(this.Calibrator.FormGetSize())));
            l.Add(new ProcessSetFormTopText("Quick Calibrate"));
            l.Add(new ProcessSetFormBottomText("Look at this"));
            l.Add(new ProcessGazeClick(SetConfig));
            l.Add(new ProcessSetFormBottomText("Done"));
            l.Add(new ProcessWait(500));

            return l;
        }

        private void SetConfig(GazeClickEventArgs e)
        {
            Point offset = new Point(_Center.X - e.Position.X,
                _Center.Y - e.Position.Y);

            Calibrator.Config.ScreenOffset = offset;
        }
    }
}
